package com.zkthink.ceres.promotion.service.impl;

import com.zkthink.base.service.SuperServiceImpl;
import com.zkthink.ceres.promotion.dao.SalesRelationConfigMapper;
import com.zkthink.ceres.promotion.entity.SalesLevel;
import com.zkthink.ceres.promotion.entity.SalesPromConfig;
import com.zkthink.ceres.promotion.entity.SalesRelationConfig;
import com.zkthink.ceres.promotion.service.SalesLevelService;
import com.zkthink.ceres.promotion.service.SalesPromConfigService;
import com.zkthink.ceres.promotion.service.SalesRelationConfigService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 业务实现类 分销员
 * </p>
 *
 * @author kellen
 * @date 2020-08-22
 */
@Slf4j
@Service
@AllArgsConstructor
public class SalesRelationConfigServiceImpl extends
    SuperServiceImpl<SalesRelationConfigMapper, SalesRelationConfig> implements
    SalesRelationConfigService {

  private SalesLevelService salesLevelService;

  private SalesPromConfigService salesPromConfigService;


  @Override
  public SalesRelationConfig queryByTenantCode(String tenantCode) {
    return this.baseMapper.queryByTenantCode(tenantCode);
  }

  private void initSalesConfig() {
    salesLevelService.save(SalesLevel.builder().isDefault(1).build());
    salesPromConfigService.save(SalesPromConfig.builder().type(1).build());
    salesPromConfigService.save(SalesPromConfig.builder().type(2).build());
    this.save(SalesRelationConfig.builder().build());
  }
}
